Conversation
Add 23 new test methods covering: - addInt64 boundary values (zero, positive, max) - addArray with 0, 1, and multiple items - addStringArray with 0, 1, and multiple strings - Fluent chaining verification - Boundary values for UInt32, UInt64, Int8 - Out-of-range validation for Int8, Int16, Int32, UInt32 Total: 51 tests, 61 assertions (was 28/31)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #186
Problem
`WriteBuffer` (159 lines, 15 public methods) has only 14 tests covering basic operations. Missing coverage:
Expected tests
```php
public function testAddInt64(): void
{
$buf = (new WriteBuffer())->addInt64(-1);
$this->assertSame(str_repeat("\xFF", 8), $buf->getContents());
}
public function testAddInt64MaxValue(): void
{
$buf = (new WriteBuffer())->addInt64(PHP_INT_MAX);
$this->assertSame(pack('J', PHP_INT_MAX), $buf->getContents());
}
public function testAddArray(): void
{
$item1 = new PublishedMessage(0, 'hello');
$item2 = new PublishedMessage(1, 'world');
$buf = (new WriteBuffer())->addArray($item1, $item2);
// Verify: int32 count + item1 binary + item2 binary
}
public function testAddStringArray(): void
{
$buf = (new WriteBuffer())->addStringArray('foo', 'bar');
// Verify: int32 count + string1 + string2
}
public function testFluentChaining(): void
{
$buf = (new WriteBuffer())
->addUInt16(0x0001)
->addUInt16(0x0001)
->addUInt32(1)
->addString('test');
// Verify complete binary output
}
public function testUInt32MaxValue(): void
{
$buf = (new WriteBuffer())->addUInt32(0xFFFFFFFF);
$this->assertSame("\xFF\xFF\xFF\xFF", $buf->getContents());
}
```
Acceptance criteria